import { post, get } from '@/utils/request'

const prefix = 'store'

export default {
  /**
   * 商品删除操作
   */
  recommend: (data, id) => {
    return post(`${prefix}/recommend/update?id=${id}`, data)
  },
  /**
   * 商品删除操作
   */
  removeRecommend: id => {
    return post(`${prefix}/recommend/remove?id=${id}`)
  },
  /**
   * 商品删除操作
   */
  updateIndex: (data, id, postMethod = true) => {
    if (postMethod) {
      return post(`${prefix}/update/index?id=${id}`, data)
    } else {
      return get(`${prefix}/update/index?id=${id}`)
    }
  },
  /**
   * 商品删除操作
   */
  categoryApply: (data, postMethod = true) => {
    if (postMethod) {
      return post(`${prefix}/category/apply`, data)
    } else {
      return get(`${prefix}/category/apply`)
    }
  },

  /**
   * 商家服务申请
   */
  service: () => {
    return get(`${prefix}/service/index`)
  },

  /**
   * 商家服务申请开通
   */
  serviceApply: data => {
    return post(`${prefix}/service/apply`, data)
  },

  /**
   * 商家服务申请开通
   */
  serviceView: id => {
    return get(`${prefix}/service/view`, {
      id: id
    })
  },

  /**
   * 商家服务申请操作
   */
  serviceHandle: (handle, data, id, postMethod = true) => {
    if (postMethod) {
      return post(`${prefix}/service-handle/${handle}?id=${id}`, data)
    } else {
      return get(`${prefix}/service-handle/${handle}?id=${id}`)
    }
  }
}
